import requests

from common.public_variable import headers


class Base:
    def send_requests(self,method,url,data = None,json=None,params=None):
        response = None
        if method == 'post':
            response = requests.post(url = url,data=data,json=json,headers=headers)
        elif method == 'get':
            response = requests.get(url = url,params = params,headers=headers)

        code = response.status_code
        res_body = response.json()
        return code, res_body
        # response = requests.post(url, headers=headers, json=body)
        # # 查看状态码，常用
        # code = response.status_code
        # # 查看响应体
        # res_body = response.json()
        # return code, res_body
